<?php
/**
 * This file is form http://findcat.cn
 *
 * @link     https://findcat.cn
 * @email    1476982312@qq.com
 */
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

//用户相关路由
Auth::routes();

//第三方授权相关
Route::namespace('Auth')->prefix('auth/oauth')->group(function () {
    Route::get('qq', 'SocialiteLoginController@redirectToProvider');
    Route::get('handleProviderCallback/qq', 'SocialiteLoginController@handleProviderCallback');
});

//前端代码
Route::namespace('Home')->group(function () {
    //ajax接口
    Route::group([], function () {
        Route::get('hot_article', 'IndexController@hotArticle')->name('hot.article');
        Route::get('every_day_content', 'IndexController@everyDayContent')->name('every_day_content.article');
        Route::get('website_announcement', 'IndexController@websiteAnnouncement')->name('website.announcement');
        Route::post('article_clicks', 'IndexController@articleClicks')->name('article_clicks.articleClicks');
        Route::get('menu', 'IndexController@menu')->name('index.menu');
    });

    Route::middleware('web')->group(function () {
        Route::post('article/comment', 'CommentController@userComment')->name('comment.index');
    });

    //常用路由
    Route::get('/', 'IndexController@index')->name('index.index');
    Route::get('article/{article_id}', 'ArticleController@show')->name('article.show');
    Route::get('category/{category_id}', 'CategoryController@show')->name('category.show');
    Route::get('tags', 'TagController@index')->name('tag.index');
    Route::get('readers', 'ReaderController@index')->name('readers.index');
    Route::get('links', 'FriendlyLinkController@index')->name('friendly_links.index');
    Route::get('tags/{tag_id}', 'TagController@show')->name('tag.show');
    Route::post('search', 'SearchController@index')->name('search.index');
    Route::get('page/upgrade-browser', 'CommonPageController@upgradeBrowser')->name('common_upgrade_browser.index');
});

Route::namespace('Admin')->prefix('admin/api')->group(function () {
    Route::post('editor_md/images', 'UploadController@upload')->name('api.upload');
});

Route::group([
    'prefix'     => config('admin.route.prefix'),
    'middleware' => config('admin.route.middleware'),
], function () {
    Route::namespace('\Encore\Admin\Controllers')->group(function () {
        Route::resource('admin_users', 'UserController')->names('admin.users');
        Route::resource('roles', 'RoleController')->names('admin.roles');
        Route::resource('permissions', 'PermissionController')->names('admin.permissions');
        Route::resource('menu', 'MenuController', ['except' => ['create']])->names('admin.menu');
        Route::resource('logs', 'LogController', ['only' => ['index', 'destroy']])->names('admin.logs');
        Route::post('_handle_form_', 'HandleController@handleForm')->name('admin.handle-form');
        Route::post('_handle_action_', 'HandleController@handleAction')->name('admin.handle-action');
    });

    Route::namespace(config('admin.route.namespace'))->group(function () {
        Route::get('/', 'DashboardController@index')->name('admin.admin');
        Route::get('dashboard', 'DashboardController@index')->name('admin.dashboard');
        Route::get('auth/login', 'AuthController@getLogin')->name('admin.login');
        Route::post('auth/login', 'AuthController@postLogin');
        Route::get('auth/logout', 'AuthController@getLogout')->name('admin.logout');
        Route::get('auth/setting', 'AuthController@getSetting')->name('admin.setting');
        Route::put('auth/setting', 'AuthController@putSetting');

        //博客内容开始
        Route::resource('articles', 'ArticleController');
        Route::resource('tags', 'TagController');
        Route::resource('categories', 'CategoryController');
        Route::resource('users', 'UserController');
        Route::resource('friend/link', 'FriendlyLinkController');
        Route::resource('web/site', 'WebSiteController');
        Route::resource('every/day/content', 'EveryDayContentController');
        Route::resource('comment', 'CommentController');
        Route::resource('user/oauth', 'UserOauthController');
        Route::resource('student/info', 'StudentInfoController');
        Route::resource('tool/birthday', 'BirthdayToolController');
    });
});
